<?php
declare (strict_types = 1);
namespace app\admin\model\data;

use app\course\model\live\admin\Live;
use app\common\model\ProductType;

/**
 * 大班课订单统计数据
 */
class LiveOrder extends PaymentOrderItem
{
    /**
     * 全局查询范围
     * @var [type]
     */
    protected $globalScope = ['product'];

    /**
     * 产品类型
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-07-04
     * @param    [type]                         $query [description]
     * @return   [type]                                [description]
     */
    public function scopeProduct($query)
    {
        $query->where('product_type_id', ProductType::getProductIdByKey('live'));
    }

    /**
     * 产品名称
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-07-04
     * @return   [type]                         [description]
     */
    public function course()
    {
        return $this->belongsTo(Live::class, 'product_id')->with(['coverUrl'])->bind(['product_title' => 'title'])->removeOption('soft_delete');
    }
}
